#!/usr/bin/env python
# -*- coding:utf-8 -*-

# file:do_file.py
# author:wmf
# datetime:2021/3/27 10:42
# software: PyCharm
'''
this is function description
'''
# import module your need

import os

print('当前工作目录:',os.getcwd())

f = open('test.txt','w')

# f = open('test.txt','a')

# f = open(r'D:\test.txt','w',encoding='gbk')

f.write("Python是一个非常好的语言。\n是的非常好!!\n")
f.close()

f1 = open('test.txt','r',encoding='gbk')
str = f1.read()
print(str)
f1.close()

#用with关键词，不需要显示地关闭文件对象

with open('test.txt','r',encoding='gbk') as f:
    print(f.read())
